{% extends 'base.html' %}
{% block title %}
Создание запроса
{% endblock %}

{% block content %}
<div id="overlay" class="no-show">
    <div class="mt-5 center">
        <img src="{{ url_for('static', filename='/images/logo.png') }}" alt="Comrade Wolf">
    </div>
    <div class="container">
        <h2 class="center">Запрос сформирован</h2>
    <div id="sql-text">

    </div>

    <div class="mt-5">
        <button type="button" class="btn btn-outline-secondary" onclick="closeOverlay()">Закрыть</button>
    </div>
        </div>

</div>
<div class="container">
    <div class="row">
        <div class="col-sm-3" id="all-fields">
            <p><b>Поля</b></p>

            <button type="button" class="btn btn-light btn-sm" id="to-select" onclick="changeAddition()" disabled>select</button>
            <button type="button" class="btn btn-outline-dark btn-sm" id="to-where" onclick="changeAddition()">where</button>

            {% for key_head, value_iter in front_fields.items() %}
            <p><b>{{key_head}}</b></p>

                {% for key, value in value_iter.items() %}
                    <button type="button" class="btn btn-sm mb-1 text-left {{value['type']}}
                    {% if value['type']=='select' %}btn-primary select-front{% endif %}
                    {% if (value['type']=='calculation') %}btn-info calculation-front{% endif %}
                    {% if (value['type']=='value') %}btn-warning value-front{% endif %}
                    {% if (value['type']=='where') %}btn-secondary where-front{% endif %}
                    {{ value['front_field_type'] }}"
                            value="{{ value['field']}}"
                    {% if value['type']=='where' %}onclick="includeIntoWhere(event)"{% else %}onclick="includeIntoQuery(event)"{% endif %}>
                        {{key}}
                    </button>
                    <br/>
                {% endfor %}
            {% endfor %}
        </div>
        <div class="col container-fluid">
            <p><b>Выбранные поля</b></p>
            <div id="control-over-selected-fields" class="mb-1 text-right">
                <button type="button" class="btn btn-outline-info btn-sm mr-1 control" id="aggregate-field" onclick="addDropdown()" disabled>Вычисление поля</button>
                <button type="button" class="btn btn-outline-danger btn-sm mr-1 control" id="delete-field" onclick="deleteSelected()"  disabled>Удалить</button>
            </div>
            <div class="height-35 c-darker" id="select-field">

            </div>
            <p><b>Where</b></p>
            <div id="control-over-where-fields" class="mb-1 text-right">
                <button type="button" class="btn btn-outline-info btn-sm mr-1 control" id="or" onclick="addOr()">ИЛИ</button>
                <button type="button" class="btn btn-outline-info btn-sm mr-1 control" id="and" onclick="addAnd()">И</button>
                <button type="button" class="btn btn-outline-danger btn-sm mr-1 control" id="delete-field-where" onclick="deleteField()"  disabled>Удалить поле</button>
                <button type="button" class="btn btn-outline-danger btn-sm mr-1 control" id="delete-or-and" onclick="deleteOrAnd()"  disabled>Удалить И/Или</button>
            </div>
            <div class="height-35 c-darker" id="where-field">

            </div>
            <div>
                <button type="button" class="btn btn-primary" onclick="generateFieldsAndWhere()">Вычисление поля</button>
            </div>

        </div>

    </div>

</div>
<script type="text/javascript" src="{{ url_for('static', filename='move_query_items.js') }}"></script>
{% endblock %}